package com.fc.v2.controller.gen;

import com.fc.v2.common.base.BaseController;
import com.fc.v2.common.domain.AjaxResult;
import com.fc.v2.common.domain.ResultTable;
import com.fc.v2.model.custom.Tablepar;
import com.fc.v2.model.auto.ApplyParticipator;
import com.fc.v2.service.ApplyParticipatorService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * 课题主要参与者Controller
 * @ClassName: ApplyParticipatorController
 * @author Archie
 * @date 2021-11-04 16:39:27
 */
@Api(value = "课题主要参与者")
@Controller
@RequestMapping("/ApplyParticipatorController")
public class ApplyParticipatorController extends BaseController{
	
	private String prefix = "gen/applyParticipator";
	
	@Autowired
	private ApplyParticipatorService applyParticipatorService;
	
	
	/**
	 * 课题主要参与者页面展示
	 * @param model
	 * @return String
	 * @author Archie
	 */
	@ApiOperation(value = "分页跳转", notes = "分页跳转")
	@GetMapping("/view")
	@RequiresPermissions("gen:applyParticipator:view")
    public String view(ModelMap model)
    {
        return prefix + "/list";
    }


	/**
	 * 立项list集合
	 * @param tablepar
	 * @param searchText
	 * @return
	 */
	//@Log(title = "课题主要参与者", action = "111")
	@ApiOperation(value = "分页跳转", notes = "分页跳转")
	@GetMapping("/list/{proId}")
	@RequiresPermissions("gen:applyParticipator:list")
	@ResponseBody
	public ResultTable list(Tablepar tablepar,ApplyParticipator applyParticipator,@PathVariable("proId") String proId){
		PageInfo<ApplyParticipator> page=applyParticipatorService.list(tablepar,applyParticipator,proId) ;
		return pageTable(page.getList(),page.getTotal());
	}

	/**
	 * 结项修改list集合
	 * @param tablepar
	 * @param searchText
	 * @return
	 */
	//@Log(title = "课题主要参与者", action = "111")
	@ApiOperation(value = "分页跳转", notes = "分页跳转")
	@GetMapping("/listEdit/{proId}/{applyId}")
	@RequiresPermissions("gen:applyParticipator:list")
	@ResponseBody
	public ResultTable listEdit(Tablepar tablepar,ApplyParticipator applyParticipator,@PathVariable("proId") String proId
								,@PathVariable("applyId") String applyId){
		PageInfo<ApplyParticipator> page=applyParticipatorService.listEdit(tablepar,applyParticipator,proId,applyId) ;
		return pageTable(page.getList(),page.getTotal());
	}

	/**
	 * 结项list集合
	 * @param tablepar
	 * @param searchText
	 * @return
	 */
	//@Log(title = "课题主要参与者", action = "111")
	@ApiOperation(value = "分页跳转", notes = "分页跳转")
	@GetMapping("/listFinish/{proId}/{proIndex}")
	@RequiresPermissions("gen:applyParticipator:list")
	@ResponseBody
	public ResultTable list(Tablepar tablepar,ApplyParticipator applyParticipator,@PathVariable("proId") String proId,
							@PathVariable("proIndex") String applyId){
		PageInfo<ApplyParticipator> page=applyParticipatorService.listFinish(tablepar,applyParticipator,proId,applyId) ;
		return pageTable(page.getList(),page.getTotal());
	}
	
	/**
     * 立项新增跳转
     */
	@ApiOperation(value = "新增跳转", notes = "新增跳转")
    @GetMapping("/add")
    public String add(ModelMap modelMap)
    {
        return prefix + "/add";
    }

	/**
	 * 结项新增跳转
	 */
	@ApiOperation(value = "新增跳转", notes = "新增跳转")
	@GetMapping("/addFinish")
	public String addFinish(ModelMap modelMap)
	{
		return prefix + "/addFinish";
	}
	
    /**
     * 新增保存
     * @param 
     * @return
     */
	//@Log(title = "课题主要参与者新增", action = "111")
	@ApiOperation(value = "新增", notes = "新增")
	@PostMapping("/add/{proId}")
	@RequiresPermissions("gen:applyParticipator:add")
	@ResponseBody
	public AjaxResult add(ApplyParticipator applyParticipator,@PathVariable("proId") String proId){
		int b=applyParticipatorService.insertSelectiveFinish(applyParticipator,proId);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}

	/**
	 * 结项新增保存
	 * @param
	 * @return
	 */
	//@Log(title = "课题主要参与者新增", action = "111")
	@ApiOperation(value = "新增", notes = "新增")
	@PostMapping("/addFinishApp/{proId}/{applyId}")
	@RequiresPermissions("gen:applyParticipator:add")
	@ResponseBody
	public AjaxResult add(ApplyParticipator applyParticipator,@PathVariable("proId") String proId,
						  @PathVariable("applyId") String applyId){
		int b=applyParticipatorService.insertSelectiveFinishApp(applyParticipator,proId,applyId);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}
	
	/**
	 * 课题主要参与者删除
	 * @param ids
	 * @return
	 */
	//@Log(title = "课题主要参与者删除", action = "111")
	@ApiOperation(value = "删除", notes = "删除")
	@DeleteMapping("/remove")
	@RequiresPermissions("gen:applyParticipator:remove")
	@ResponseBody
	public AjaxResult remove(String ids){
		int b=applyParticipatorService.deleteByPrimaryKey(ids);
		if(b>0){
			return success();
		}else{
			return error();
		}
	}
	
	
	/**
	 * 立项修改跳转
	 * @param id
	 * @param mmap
	 * @return
	 */
	@ApiOperation(value = "修改跳转", notes = "修改跳转")
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap map)
	{
		map.put("ApplyParticipator", applyParticipatorService.selectByPrimaryKey(id));

		return prefix + "/edit";
	}
	/**
	 * 结项修改跳转
	 * @param id
	 * @param mmap
	 * @return
	 */
	@ApiOperation(value = "修改跳转", notes = "修改跳转")
	@GetMapping("/editFinish/{id}")
	public String editFinish(@PathVariable("id") String id, ModelMap map)
	{
		map.put("ApplyParticipator", applyParticipatorService.selectByPrimaryKey(id));

		return prefix + "/editFinish";
	}
	
	/**
     * 修改保存
     */
    //@Log(title = "课题主要参与者修改", action = "111")
	@ApiOperation(value = "修改保存", notes = "修改保存")
    @RequiresPermissions("gen:applyParticipator:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ApplyParticipator applyParticipator)
    {
        return toAjax(applyParticipatorService.updateByPrimaryKeySelective(applyParticipator));
    }
    
    
    /**
	 * 修改状态
	 * @param record
	 * @return
	 */
    @PutMapping("/updateVisible")
	@ResponseBody
    public AjaxResult updateVisible(@RequestBody ApplyParticipator applyParticipator){
		int i=applyParticipatorService.updateVisible(applyParticipator);
		return toAjax(i);
	}

    
    

	
}
